package com.ushine.design.design.b_structural_type.f_flyweight.b_example;

/**
 * 客户端测试
 *
 * @author yls
 */
public class Client {
    public static void main(String[] args) {
        IgoChessman black00, black01, black02, black03, white00, white01, white02;
        IgoChessmanFactory factory;

        //获取亨元工厂对象
        factory = IgoChessmanFactory.getInstance();

        //通过亨元对象获取3颗棋子
        black00 = IgoChessmanFactory.getIgoChessman("b");
        black01 = IgoChessmanFactory.getIgoChessman("b");
        black02 = IgoChessmanFactory.getIgoChessman("b");
        black03 = IgoChessmanFactory.getIgoChessman("b");
        System.out.println("判断两颗棋子是否相同：" + (black00 == black01));

        white00 = IgoChessmanFactory.getIgoChessman("w");
        white01 = IgoChessmanFactory.getIgoChessman("w");
        white02 = IgoChessmanFactory.getIgoChessman("w");
        System.out.println("判断两个棋子是否相同：" + (white00 == white01));

        black00.display();
        black01.display();
        black02.display();
        black03.display();

        white00.display();
        white01.display();
        white02.display();


        System.out.println("有外部状态的亨元模式==》");
        black00.newDisplay(new Coordinates(1, 3));
        black01.newDisplay(new Coordinates(5, 4));
        black02.newDisplay(new Coordinates(2, 6));
        black03.newDisplay(new Coordinates(7, 2));

        white00.newDisplay(new Coordinates(5, 2));
        white01.newDisplay(new Coordinates(9, 5));
        white02.newDisplay(new Coordinates(10, 3));
    }
}
